package com.zjhcsoft.shop.action;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.zjhcsoft.common.action.SysAbstractAction;
import com.zjhcsoft.shop.model.User;
import com.zjhcsoft.shop.service.UserService;
import com.zjhcsoft.shop.sys.shoputil.UserUtil;

@Controller
public class UserAction extends SysAbstractAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 8066368761083005198L;
	@Resource
	private UserService userService;
	private String loginName;
	private String password;
	private String email;
	private String message;
	private User user;
	

	public String show(){
		user=UserUtil.getUserFromCookies();
		return "zhuce";
		
	}
	public String save(){
		List<User> list = userService.getUserByLoginName(loginName);
		if(list.size()==0){
			User user=new User();
			user.setLoginName(loginName);
			user.setPassword(password);
			user.setEmail(email);
			user.setCreatetime(new Date());
			user.setModifytime(new Date());
			user.setStatus(0);
			userService.saveOrUpdate(user);
			return "success";
		}else{
			message="该用户已存在，请使用其他用户名！";
			return "zhuce";
		}
		
	}
	public String getLoginName() {
		return loginName;
	}
	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	
}
